x86/PoD: Eager sweep for zeroed pages
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 29 Oct 2015 12:50:59 +0000 (13:50 +0100)
committerIan Campbell <ijc@debian.org>
Tue, 9 Feb 2016 16:41:16 +0000 (16:41 +0000)
commit0fc42b31719e90d12701ccc7f73898f3e0f9282f
tree5b427cebec7b8c17571d0a61bb15d7cc568180a8
parent288d00a054f4bb9ed1447f7799efd149772ea977
x86/PoD: Eager sweep for zeroed pages

Based on the contents of a guests physical address space,
p2m_pod_emergency_sweep() could degrade into a linear memcmp() from 0 to
max_gfn, which runs non-preemptibly.

As p2m_pod_emergency_sweep() runs behind the scenes in a number of contexts,
making it preemptible is not feasible.

Instead, a different approach is taken.  Recently-populated pages are eagerly
checked for reclaimation, which amortises the p2m_pod_emergency_sweep()
operation across each p2m_pod_demand_populate() operation.

Note that in the case that a 2M superpage can't be reclaimed as a superpage,
it is shattered if 4K pages of zeros can be reclaimed.  This is unfortunate
but matches the previous behaviour, and is required to avoid regressions
(domain crash from PoD exhaustion) with VMs configured close to the limit.

This is CVE-2015-7970 / XSA-150.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
master commit: 101ce53266866144e724ed593173bc4098b300b9
master date: 2015-10-29 13:36:25 +0100

(cherry picked from commit 4a32fbd95af6503ea1314ff2aa9a0b0a473d46c0)

Patch-Name: CVE-2015-7970.diff

Gbp-Pq: Name CVE-2015-7970.diff
xen/arch/x86/mm/p2m-pod.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/p2m.h